home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
10,000 Great Games
/
10,000 Great Games.iso
/
Product
/
66
/
data1.cab
/
Source_Files
/
Src
/
Profile.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2000-01-16
|
8KB
|
167 lines
#include "stdafx.h"
char temp_path[256], autosave_level[256], clipboard_level[256];
void read_profile()
{
// Get temporary dir
int l = GetTempPath(256, temp_path);
if (l > 0 && temp_path[l-1] != '\\')
strcat(temp_path, "\\");
// Create autosave filename
strcpy(autosave_level, temp_path);
strcat(autosave_level, AUTOSAVE_LEVEL);
// Create clipboard filename
strcpy(clipboard_level, temp_path);
strcat(clipboard_level, CLIPBOARD_LEVEL);
// Get state of edit menu
snap_to_grid = theApp.GetProfileInt(SEC_EDIT, "Snap to Grid", FALSE);
// Get state of view menu
view_backgroundarea = theApp.GetProfileInt(SEC_VIEW, "Background Area", TRUE);
view_gamearea = theApp.GetProfileInt(SEC_VIEW, "Game Area", TRUE);
view_grid = theApp.GetProfileInt(SEC_VIEW, "Grid", FALSE);
debug = theApp.GetProfileInt(SEC_VIEW, "Debug Info", FALSE);
// Get state of settings menu
no_blit_hardware = theApp.GetProfileInt(SEC_SETTINGS, "No Blit Hardware", FALSE);
no_parallax = theApp.GetProfileInt(SEC_SETTINGS, "No Parallax", FALSE);
low_detail_level = theApp.GetProfileInt(SEC_SETTINGS, "Low Detail Level", FALSE);
names_visible = theApp.GetProfileInt(SEC_SETTINGS, "Names Visible", FALSE);
no_armor = theApp.GetProfileInt(SEC_SETTINGS, "No Armor", FALSE);
gamma = (double)theApp.GetProfileInt(SEC_SETTINGS, "Gamma", 100) / 100;
// Get controls
strcpy(pl_name[0], theApp.GetProfileString(SEC_PLAYERS, "Pl1 Name", "Jorrit"));
strcpy(pl_name[1], theApp.GetProfileString(SEC_PLAYERS, "Pl2 Name", "Dennis"));
strcpy(pl_name[2], theApp.GetProfileString(SEC_PLAYERS, "Pl3 Name", "Peter"));
strcpy(pl_name[3], theApp.GetProfileString(SEC_PLAYERS, "Pl4 Name", "Steven"));
strcpy(pl_name[4], theApp.GetProfileString(SEC_PLAYERS, "Pl5 Name", "Heidi"));
strcpy(pl_name[5], theApp.GetProfileString(SEC_PLAYERS, "Pl6 Name", "Maarten"));
strcpy(pl_name[6], theApp.GetProfileString(SEC_PLAYERS, "Pl7 Name", "Reinier"));
strcpy(pl_name[7], theApp.GetProfileString(SEC_PLAYERS, "Pl8 Name", "Elmer"));
pl_selected[0] = theApp.GetProfileInt(SEC_PLAYERS, "Pl1 Selected", TRUE);
pl_selected[1] = theApp.GetProfileInt(SEC_PLAYERS, "Pl2 Selected", TRUE);
pl_selected[2] = theApp.GetProfileInt(SEC_PLAYERS, "Pl3 Selected", FALSE);
pl_selected[3] = theApp.GetProfileInt(SEC_PLAYERS, "Pl4 Selected", FALSE);
pl_selected[4] = theApp.GetProfileInt(SEC_PLAYERS, "Pl5 Selected", FALSE);
pl_selected[5] = theApp.GetProfileInt(SEC_PLAYERS, "Pl6 Selected", FALSE);
pl_selected[6] = theApp.GetProfileInt(SEC_PLAYERS, "Pl7 Selected", FALSE);
pl_selected[7] = theApp.GetProfileInt(SEC_PLAYERS, "Pl8 Selected", FALSE);
key_left[0] = theApp.GetProfileInt(SEC_CONTROLS, "Key 1 Left", DIK_LEFT);
key_right[0] = theApp.GetProfileInt(SEC_CONTROLS, "Key 1 Right", DIK_RIGHT);
key_up[0] = theApp.GetProfileInt(SEC_CONTROLS, "Key 1 Up", DIK_UP);
key_down[0] = theApp.GetProfileInt(SEC_CONTROLS, "Key 1 Down", DIK_DOWN);
key_fire[0] = theApp.GetProfileInt(SEC_CONTROLS, "Key 1 Fire", DIK_RCONTROL);
key_left[1] = theApp.GetProfileInt(SEC_CONTROLS, "Key 2 Left", DIK_Z);
key_right[1] = theApp.GetProfileInt(SEC_CONTROLS, "Key 2 Right", DIK_C);
key_up[1] = theApp.GetProfileInt(SEC_CONTROLS, "Key 2 Up", DIK_S);
key_down[1] = theApp.GetProfileInt(SEC_CONTROLS, "Key 2 Down", DIK_X);
key_fire[1] = theApp.GetProfileInt(SEC_CONTROLS, "Key 2 Fire", DIK_LCONTROL);
key_left[2] = theApp.GetProfileInt(SEC_CONTROLS, "Key 3 Left", DIK_J);
key_right[2] = theApp.GetProfileInt(SEC_CONTROLS, "Key 3 Right", DIK_L);
key_up[2] = theApp.GetProfileInt(SEC_CONTROLS, "Key 3 Up", DIK_I);
key_down[2] = theApp.GetProfileInt(SEC_CONTROLS, "Key 3 Down", DIK_K);
key_fire[2] = theApp.GetProfileInt(SEC_CONTROLS, "Key 3 Fire", DIK_SPACE);
reverse_mouse = theApp.GetProfileInt(SEC_CONTROLS, "Mouse Reverse", FALSE);
for (int i = 0; i < kMaxJoys; i++)
{
strcpy(joy_str[i], theApp.GetProfileString(SEC_CONTROLS, construct("Joy %d", i+1), ""));
joy_fire[i] = theApp.GetProfileInt(SEC_CONTROLS, construct("Joy %d Fire", i+1), DIJOFS_BUTTON0);
joy_jetpack[i] = theApp.GetProfileInt(SEC_CONTROLS, construct("Joy %d Jetpack", i+1), DIJOFS_BUTTON1);
joy_mine[i] = theApp.GetProfileInt(SEC_CONTROLS, construct("Joy %d Mine", i+1), DIJOFS_BUTTON2);
}
}
void write_profile()
{
// Delete temp files
DeleteFile(autosave_level);
DeleteFile(clipboard_level);
// Write state of edit menu
theApp.WriteProfileInt(SEC_EDIT, "Snap to Grid", snap_to_grid);
// Write state of view menu
theApp.WriteProfileInt(SEC_VIEW, "Background Area", view_backgroundarea);
theApp.WriteProfileInt(SEC_VIEW, "Game Area", view_gamearea);
theApp.WriteProfileInt(SEC_VIEW, "Grid", view_grid);
theApp.WriteProfileInt(SEC_VIEW, "Debug Info", debug);
// Write state of settings menu
theApp.WriteProfileInt(SEC_SETTINGS, "No Blit Hardware", no_blit_hardware);
theApp.WriteProfileInt(SEC_SETTINGS, "No Parallax", no_parallax);
theApp.WriteProfileInt(SEC_SETTINGS, "Low Detail Level", low_detail_level);
theApp.WriteProfileInt(SEC_SETTINGS, "Names Visible", names_visible);
theApp.WriteProfileInt(SEC_SETTINGS, "No Armor", no_armor);
theApp.WriteProfileInt(SEC_SETTINGS, "Gamma", (int)(gamma * 100));
// Write controls
theApp.WriteProfileString(SEC_PLAYERS, "Pl1 Name", pl_name[0]);
theApp.WriteProfileString(SEC_PLAYERS, "Pl2 Name", pl_name[1]);
theApp.WriteProfileString(SEC_PLAYERS, "Pl3 Name", pl_name[2]);
theApp.WriteProfileString(SEC_PLAYERS, "Pl4 Name", pl_name[3]);
theApp.WriteProfileString(SEC_PLAYERS, "Pl5 Name", pl_name[4]);
theApp.WriteProfileString(SEC_PLAYERS, "Pl6 Name", pl_name[5]);
theApp.WriteProfileString(SEC_PLAYERS, "Pl7 Name", pl_name[6]);
theApp.WriteProfileString(SEC_PLAYERS, "Pl8 Name", pl_name[7]);
theApp.WriteProfileInt(SEC_PLAYERS, "Pl1 Selected", pl_selected[0]);
theApp.WriteProfileInt(SEC_PLAYERS, "Pl2 Selected", pl_selected[1]);
theApp.WriteProfileInt(SEC_PLAYERS, "Pl3 Selected", pl_selected[2]);
theApp.WriteProfileInt(SEC_PLAYERS, "Pl4 Selected", pl_selected[3]);
theApp.WriteProfileInt(SEC_PLAYERS, "Pl5 Selected", pl_selected[4]);
theApp.WriteProfileInt(SEC_PLAYERS, "Pl6 Selected", pl_selected[5]);
theApp.WriteProfileInt(SEC_PLAYERS, "Pl7 Selected", pl_selected[6]);
theApp.WriteProfileInt(SEC_PLAYERS, "Pl8 Selected", pl_selected[7]);
theApp.WriteProfileInt(SEC_CONTROLS, "Key 1 Left", key_left[0]);
theApp.WriteProfileInt(SEC_CONTROLS, "Key 1 Right", key_right[0]);
theApp.WriteProfileInt(SEC_CONTROLS, "Key 1 Up", key_up[0]);
theApp.WriteProfileInt(SEC_CONTROLS, "Key 1 Down", key_down[0]);
theApp.WriteProfileInt(SEC_CONTROLS, "Key 1 Fire", key_fire[0]);
theApp.WriteProfileInt(SEC_CONTROLS, "Key 2 Left", key_left[1]);
theApp.WriteProfileInt(SEC_CONTROLS, "Key 2 Right", key_right[1]);
theApp.WriteProfileInt(SEC_CONTROLS, "Key 2 Up", key_up[1]);
theApp.WriteProfileInt(SEC_CONTROLS, "Key 2 Down", key_down[1]);
theApp.WriteProfileInt(SEC_CONTROLS, "Key 2 Fire", key_fire[1]);
theApp.WriteProfileInt(SEC_CONTROLS, "Key 3 Left", key_left[2]);
theApp.WriteProfileInt(SEC_CONTROLS, "Key 3 Right", key_right[2]);
theApp.WriteProfileInt(SEC_CONTROLS, "Key 3 Up", key_up[2]);
theApp.WriteProfileInt(SEC_CONTROLS, "Key 3 Down", key_down[2]);
theApp.WriteProfileInt(SEC_CONTROLS, "Key 3 Fire", key_fire[2]);
theApp.WriteProfileInt(SEC_CONTROLS, "Mouse Reverse", reverse_mouse);
for (int i = 0; i < kMaxJoys; i++)
{
theApp.WriteProfileString(SEC_CONTROLS, construct("Joy %d", i+1), joy_str[i]);
theApp.WriteProfileInt(SEC_CONTROLS, construct("Joy %d Fire", i+1), joy_fire[i]);
theApp.WriteProfileInt(SEC_CONTROLS, construct("Joy %d Jetpack", i+1), joy_jetpack[i]);
theApp.WriteProfileInt(SEC_CONTROLS, construct("Joy %d Mine", i+1), joy_mine[i]);
}
}